from rest_framework_jwt.authentication import jwt_decode_handler
from user.models import User


def get_token_user(request):
    """获取token中的user_id"""
    token = request.auth
    deploy = jwt_decode_handler(token)
    user_id = deploy['user_id']
    user = User.objects.get(id=user_id)
    return user